package com.rockcent.common.helper;

import com.rockcent.common.utils.RDigestUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.util.Date;
import java.util.Random;

/**
 * Created by oyhk on 16/5/13.
 */
public class CommonHelper {
    /**
     * 识别号生成 md5
     * @return
     */
    public String createIdentifier() {
        return RDigestUtils.md5Hex((new Random().nextInt(899999) + 100000) + "" + new Date().getTime());
    }

    /**
     * 生成编号
     * @return
     */
    public static String getNumber() {
        Instant instant = Instant.now();
        String orderNumber = DateFormatUtils.format(Date.from(instant), "yyyyMMddHHmmddSSS");
        return orderNumber + "_" + String.valueOf(new Random().nextInt(899999) + 100000);
    }
}
